<script setup>
import { useRoute,useRouter } from 'vue-router';
import { ElMessage,ElMessageBox  } from 'element-plus';
import { getTreatList } from '@/api/Member/index.js'
const props = defineProps({
    uuid:{
        default:"",
        type:[String,Number]
    }
})
const detailFlag = ref(false);
const infoTitle = ref("");
const detailInfo = ref({})
const recordList = ref([]);
const pageLoading = ref(false);
const img1 = ref(new URL("@/assets/images/login-bg3.png",import.meta.url))
const _getTreatList = async ()=>{
    try{
        pageLoading.value = true;
        let params = {
            storeId: "",
            orderBy: "",
            rule:"",
            "page.size":99999,
            "page.current":1,
            memberId:props.uuid,
            enterpriseId: "",
            type:1
        }
        let result = await getTreatList(params);
        recordList.value =  result.records.map(lis=>{
            let treatDay = lis.treatDay?lis.treatDay.split(" "):[];

            treatDay = treatDay[0]?treatDay[0].split("-"):[];
            let imgList = [];
            let illnessUrl = lis.illnessUrl.split(',').filter(lis=>{
                return lis != "";
            })
            let treatUrl = lis.treatUrl.split(',').filter(lis=>{
                return lis != "";
            })

            imgList = [...illnessUrl,...treatUrl].filter(lis=>{
                return lis != "";
            })
            let packageName = lis.projectList.map(lis=>{
                return lis.projectName
            }).join(',');
            return {
                ...lis,
                monthAndDay:treatDay[1] && treatDay[2]?treatDay[1]+'/'+treatDay[2]:"-",
                year:treatDay[0],
                imgList,
                packageName,
                dateInfo:treatDay.join("-"),
                illnessUrl,
                treatUrl
            }
        })

    }catch(e){
        console.log(e);
    }finally{
        pageLoading.value = false;
    }
}
_getTreatList();
const lookDetail = (info)=>{
    detailInfo.value = info;
    infoTitle.value = info.isPackage == 1?`【${ info.dateInfo }】${ info.projectName }(${ info.useFrequency || 0 }/${ info.countFrequency || 0})`:`【${ info.dateInfo }】${ info.projectName}`;
    detailFlag.value = true;
}
</script>
<template>
    <div class="record-area"  v-loading="pageLoading">
        <template v-if="recordList.length>0">
            <div class="record-lis" v-for="(item,index) in recordList" :key="index" @click="lookDetail(item)">
                <div class="date">
                    <div class="p1">
                        {{ item.monthAndDay }}
                    </div>
                    <div class="p2">
                        {{ item.year }}
                    </div>
                </div>
                <div class="chat-info" style="border-right:0">
                    <div class="store-info">
                        
                        <div class="name-info" style="margin-left:0;margin-right:17px">
                            {{ item.projectName || '-' }}
                            <span v-if="item.isPackage == 1">
                
                                ({{ item.useFrequency || 0 }}
                                /
                                {{ item.countFrequency || 0}})
                            </span>
                        </div>
                        <img src="@/assets/icon/store-name.png" alt="" class="img1" style="margin-right:5px">
                        <span style="margin-right:16px">{{ item.storeName || '-' }}</span>
                        <div class="s-line" v-if="item.imgList.length<=0 && item.writeEmployeeName && item.auditEmployeeName"></div>
    
                        <div class="person" v-if="item.writeEmployeeName">
                            <img src="@/assets/icon/blue-p.png" alt="" class="img2">
                            <span>{{ item.writeEmployeeName }}</span>
                        </div>
                        <div class="person2" v-if="item.auditEmployeeName">
                            <img src="@/assets/icon/blue-g.png" alt="" class="img2">
                            <span>{{ item.auditEmployeeName }}</span>
                        </div>

                    </div>
                    <div class="icon-info" v-if="item.isPackage == 1">
                        <div class="icon-lis" style="width:100%">
                            <div class="l-name">疗程项目</div>
                            <div class="r-name">{{ item.packageName }}</div>
                        </div>
                    </div>
                    <div class="icon-info" v-else>
                        <template v-for="(lis,key) in item.projectList" :key="key">
                            <div class="icon-lis" v-for="(i,k) in lis.attribute" :key="k">

                                <div class="l-name">{{ i.attributeName }}</div>
                                <div class="r-name">{{ i.attributeValue }}</div>
                            </div>

                        </template>

                    </div>
                    <div class="speak-block">
                        <div class="lis-speak">
                            <div class="speak-p">
                                客户反馈：
                            </div>
                            <div class="speak-i">
                                {{ item.feedBack || '-' }}
                            </div>
                        </div>
                        <div class="lis-speak">
                            <div class="speak-p">
                                康复备注：
                            </div>
                            <div class="speak-i">
                                {{ item.remark  || '-' }}
                            </div>
                        </div>
                    </div>

                </div>
                <div class="img-show" v-if="item.imgList.length>0">
                    <div class="person-lis">
                        <div class="person" v-if="item.auditEmployeeName">
                            <img src="@/assets/icon/blue-p.png" alt="" class="img2">
                            <span>{{ item.auditEmployeeName }}</span>
                        </div>
                        <div class="person2" v-if="item.writeEmployeeName">
                            <img src="@/assets/icon/blue-g.png" alt="" class="img2">
                            <span>{{ item.writeEmployeeName }}</span>
                        </div>
                    </div>
                    <div class="img-b" v-if="item.imgList && item.imgList.length>0">
                        <div class="mask" style="pointer-events: none;" v-if="item.imgList.length>1">
                            +{{ item.imgList.length }}
                        </div>
                        <div style="position:relative">
                            <div class="img2" >
                                <el-image
                                    :src="item.imgList[0]"
                                    :zoom-rate="1.2"
                                    :preview-src-list="item.imgList"

                                    style="width:100px;height:100px"
                                />
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </template>
        <div class="empty-data" v-else>
            <div class="empty-img">
                <div class="text">暂无康复记录</div>
            </div>
        </div>
    </div>
    <el-drawer
            v-model="detailFlag"
            :title="infoTitle"
            direction="rtl"
            width="600px"
        >
            <div class="info-contain">
                <div class="base-info">
                    <div class="p1">
                        <img src="@/assets/icon/store-name.png" alt="" class="img1" style="margin-right:5px">
                        {{ detailInfo.storeName || '-' }}
                    </div>
                    <div class="p2">
                        <div class="lis">
                            <div class="person" v-if="detailInfo.auditEmployeeName">
                                <img src="@/assets/icon/blue-p.png" alt="" class="img2">
                                <span>{{ detailInfo.auditEmployeeName }}</span>
                            </div>
                            <span style="margin-left:10px">
                                {{ detailInfo.auditTime }}
                            </span>
                        </div>
                        <div class="lis">
                            <div class="person2" v-if="detailInfo.writeEmployeeName">
                                <img src="@/assets/icon/blue-g.png" alt="" class="img2">
                                <span>{{ detailInfo.writeEmployeeName }}</span>
                            </div>
                            <span style="margin-left:10px">
                                {{ detailInfo.writeTime }}
                            </span>
                        </div>
                    </div>
                </div>
                <div class="summary">
                    <template v-for="(item,index) in detailInfo.projectList" :key="index">
                        <div class="lis-head">
                            <div class="icon-view">
                                <div class="icon-view-on"></div>
                            </div>
                            <span class="label-name">{{ item.projectName }}</span>
                        </div>
                        <div class="lis-info" >
                            <div class="icon-lis" v-for="(lis,key) in item.attribute" :key="key">

                                <div class="l-name">{{ lis.attributeName}}：</div>
                                <div class="r-name">{{ lis.attributeValue}}</div>
                            </div>

                        </div>
                    </template>
                </div>
                <div class="summary" style="border-bottom:0">
                    <div class="lis-info">
                        <div class="icon-lis" style="width:100%">
                            <div class="l-name">客户反馈：</div>
                            <div class="r-name">{{ detailInfo.feedBack }}</div>
                        </div>
                        <div class="icon-lis" style="width:100%">
                            <div class="l-name">康复备注：</div>
                            <div class="r-name">{{ detailInfo.remark }}</div>
                        </div>
                        <div class="icon-lis" style="width:100%">
                            <div class="l-name">
                                <div style="font-size:14px;width:100%">患处图片：</div>
                                <div style="font-size:14px;width:100%">(康复前)</div>
                            </div>
                            <div class="r-name">
                                <div class="img-lis" v-for="(item,index) in detailInfo.illnessUrl" :key="index">
                                    <el-image
                                        :src="item"
                                        :zoom-rate="1.2"
                                        :preview-src-list="[item]"
                                        :initial-index="4"
                                        style="width:120px;height:120px"
                                        />
                                </div>
                            </div>
                        </div>
                        <div class="icon-lis" style="width:100%">
                            <div class="l-name">
                                <div style="font-size:14px;width:100%">患处图片：</div>
                                <div style="font-size:14px;width:100%">(康复前)</div>
                            </div>
                            <div class="r-name">
                                <div class="img-lis" v-for="(item,index) in detailInfo.treatUrl" :key="index">
                                    <el-image
                                        :src="item"
                                        :zoom-rate="1.2"
                                        :preview-src-list="[item]"
                                        :initial-index="4"
                                        style="width:120px;height:120px"
                                        />
                                </div>
                                
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </el-drawer>
</template>
<style lang="less" scoped>
.info-contain{
    width: 100%;
    .base-info{
        width: 100%;
        padding-top:12px;
        padding-bottom:16px;
        border-bottom:1px solid #DDDDDD;
        .p2{
            padding-top:8px;
            width: 100%;
            display: flex;
            justify-items: flex-start;
            .lis{
                width: 50%;
                display: flex;
                align-items: center;
                color: #666666;
                font-size: 14px;
                font-weight: 400;
                .person{
                    display: flex;
                    justify-content: flex;
                    border-radius: 4px;
                    background: rgba(52, 128, 255, 0.1);
                    padding: 7px 8px;
                    color: #3480ff;
                    font-size: 14px;
                    line-height: 14px;
                    .img2{
                        width: 14px;
                        height: 14px;
                        margin-right: 4px;
                    }
                }
                .person2{
                    display: flex;
                    justify-content: flex;
                    border-radius: 4px;
                    background: rgba(232, 249, 239, 1);
                    padding: 7px 8px;
                    color: #18BF5B;
                    font-size: 14px;
                    line-height: 14px;
                    .img2{
                        width: 14px;
                        height: 14px;
                        margin-right: 4px;
                    }
                }
            }
        }
        .p1{
            width: 100%;
            display: flex;
            justify-content: flex-start;
            color: #222222;
            font-size: 14px;
            font-weight: bold;
            line-height: 14px;
            .img1{
                width: 18px;
                height: 18px;
                margin-right: 8px;
            }
        }
    }
    .summary{
        width: 100%;
        padding-top:16px;
        border-bottom:1px solid #DDDDDD;
        .lis-head{
            width: 100%;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            margin-bottom:16px;
            .icon-view{
                margin-right: 8px;
                position: relative;
                width: 14px;
                height: 14px;

                &::before {
                    content: "";
                    position: absolute;
                    top: 0;
                    left: 0;
                    width: 10px;
                    height: 10px;
                    border-radius: 2px;
                    background-color: #10E7F9; 
                }
                .icon-view-on{
                    position: absolute;
                    bottom: 0;
                    right: 0;
                    width: 10px;
                    height: 10px;
                    border-radius: 2px;
                    background-color: #3480FF; /* 背景色 */
                }
            }
            .label-name{
                color: #000000;
                font-weight: bold;
                font-size: 14px;
                margin-right: 8px;
            }
            img{
                width: 14px;
                height: 14px;
                cursor: pointer;
            }
        }
        .lis-info{
            width: 100%;
            display: flex;
            justify-content: flex-start;
            flex-wrap: wrap;
            .icon-lis{
                margin-bottom:16px;
                width: 50%;
                display: flex;
                justify-content: flex-start;
                align-items: flex-start;

                .l-name{
                    color: #222222;
                    font-size: 14px;
                    width: 70px;
                    text-align: left;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    overflow: hidden;
                }
                .r-name{
                    width: calc(100% - 70px);
                    color: #222222;
                    font-size: 14px;
                    word-break: break-all;
                    word-wrap: break-word;
                    display: flex;
                    justify-content: flex-start;
                    flex-wrap: wrap;
                    line-height: 20px;
                    .img-lis{
                        margin-right: 4px;
                        margin-bottom:4px;
                        width: 120px;
                        height: 120px;
                    }
                }
            }
        }
    }
}
.empty-data{
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .empty-img{
        width: 300px;
        height: 200px;
        background: url('@/assets/images/empty-table.png');
        background-size: 100% 100%;
        position: relative;
        .text{
            position: absolute;
            bottom:0;
            width: 100%;
            text-align: center;
            color: #666666;
            line-height: 14px;
            font-size: 14px;

        }
    }
}
.record-area{
    width: 100%;
    min-height: 40%;
    .record-lis{
        width: 100%;
        display: flex;
        justify-content: flex-start;
        margin-bottom:16px;
        background: #f6f6f6;
        padding:16px 0;
        border-radius: 4px;
        cursor: pointer;
        .person{
            display: flex;
            justify-content: flex;
            border-radius: 4px;
            background: rgba(52, 128, 255, 0.1);
            padding: 7px 8px;
            color: #3480ff;
            font-size: 14px;
            line-height: 14px;
            .img2{
                width: 14px;
                height: 14px;
                margin-right: 4px;
            }
        }
        .person2{
            display: flex;
            justify-content: flex;
            border-radius: 4px;
            background: rgba(232, 249, 239, 1);
            padding: 7px 8px;
            color: #18BF5B;
            font-size: 14px;
            line-height: 14px;
            .img2{
                width: 14px;
                height: 14px;
                margin-right: 4px;
            }
        }
        .date{
            width: 90px;
            box-sizing: border-box;
            padding:12px;
            padding-right: 0px;
            .p1{
                color: #000000;
                width:100%;
                font-size: 24px;
                font-weight: bold;
                line-height: 24px;
            }
            .p2{
                color: #000000;
                width:100%;
                font-size: 16px;
                font-weight: bold;
                line-height: 16px;
                margin-top:8px;
            }
        }
        .img-show{
            box-sizing:border-box;
            padding:16px;
            padding-top:0px;
            border-left:1px solid #DDDDDD;
            .person-lis{
                width: 100%;
                margin-bottom:8px;
                display: flex;
                justify-content: flex-start;

            }
            .img-b{
                position: relative;
                width: 100px;
                height: 100px;
                .img1{
                    width: 100%;
                    height: 100%;
                    border-radius: 4px;
                    position: absolute;
                    top:0;
                    left:0;
                    z-index: 1;
                }
                .mask{
                    width: 100%;
                    height: 100%;
                    border-radius: 4px;
                    background: rgba(0, 0, 0, 0.4);   
                    top:0;
                    left:0;
                    position: absolute;
                    z-index: 2;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    font-size: 20px;
                    color:#fff;
                    font-weight: bold;
                }
                .img2{
                    width: 100%;
                    height: 100%;
                    border-radius: 4px;


                }
            }
        }
        .chat-info{
            padding:0 16px;
            box-sizing: border-box;
            border-left:1px solid #DDDDDD;
            border-right:1px solid #DDDDDD;
            .store-info{
                width: 100%;
                display: flex;
                justify-content: flex-start;
                padding-top:5px;
                padding-bottom:16px;
                align-items:center;
                .img1{
                    width: 18px;
                    height: 18px;
                }
                .name-info{
                    margin-left:4px;
                    margin-right:16px;
                    color:#000;
                    font-weight:bold;
                    line-height: 18px;
                    font-size: 18px;
                }
                .name-info2{
                    color:#222222;
                    font-size: 14px;
                    line-height: 14px;
                }
                .s-line{
                    width: 1px;
                    height: 48px;
                    background:#DDDDDD;
                    margin-right: 16px;
                }

            }
            .icon-info{
                width: 100%;
                display: flex;
                justify-content: flex-start;
                flex-wrap: wrap;

                .icon-lis{
                    margin-bottom:16px;
                    width: 50%;
                    display: flex;
                    justify-content: flex-start;
                    align-items: center;
                    .icon-1{
                        width: 14px;
                        height: 14px;
                    }
                    .l-name{
                        color: #222222;
                        font-size: 14px;
                        margin-left:4px;
                        margin-right: 16px;

                    }
                    .r-name{
                        color: #FF6B00;
                        font-size: 14px;

                        margin-right: 16px;
                    }
                }
            }
            .speak-block{
                width: 720px;
                padding: 12px;
                box-sizing: border-box;
                background: #fff;
                border-radius: 4px;
                .lis-speak{
                    width: 100%;
                    display: flex;
                    justify-content: flex-start;
                    margin-bottom:16px;
                    &:last-child{
                        margin-bottom: 0;
                    }
                    .speak-p{
                        width: 70px;
                        color: #000000;
                        font-size: 14px;
                        font-weight: bold;
                        line-height: 14px;
                    }
                    .speak-i{
                        width: calc(100% - 70px);
                        color: #222222;
                        font-size: 14px;
                        line-height: 14px;
                        word-break: break-all;
                        word-wrap: break-word;
                    }
                }
            }
        }
    }
}
</style>